#include "gotocellocation.h"
#include <qregexp.h>
#include <qmessagebox.h>
#include <QRegExpValidator>

GoToCelLocation::GoToCelLocation(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);

	connect(ui.lineEdit,SIGNAL(textChanged(const QString & text)),this,SLOT(on_lineEdit_textChanged()));
	connect(ui.cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
	connect(ui.okButton,SIGNAL(clicked()),this,SLOT(on_okbutton_clicked()));
	connect(ui.okButton,SIGNAL(clicked()),this,SLOT(accept()));
	// 第1个为字母，第2个为1-9的数字，再加上0-2个0-9的数字
	QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
	ui.lineEdit->setValidator(new QRegExpValidator(regExp,this));

}

GoToCelLocation::~GoToCelLocation()
{

}

void GoToCelLocation::on_lineEdit_textChanged()
{
	//QMessageBox::information(this,"Infor","OnTextChanged");
	ui.okButton->setEnabled(ui.lineEdit->hasAcceptableInput());
}
void GoToCelLocation::on_okbutton_clicked()
{
	QMessageBox::information(this,"Infor","Input Text Validated");
	accept();
}
